﻿<Window x:Class="ZapHelper.TestApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525"  FlowDirection="RightToLeft">
    <Window.Resources>

        <DataTemplate x:Key="ProductTemplate">
            <TreeViewItem Header="{Binding Path=Name, IsAsync=True}">
                <StackPanel Orientation="Vertical">

                    <StackPanel Orientation="Horizontal">
                        <Label Content="מחיר: " />
                        <Label Content="{Binding Path=Price, IsAsync=True}"/>
                    </StackPanel>

                    <StackPanel Orientation="Horizontal">
                        <Label Content="כתובת: " />
                        <Label Content="{Binding Path=Url, IsAsync=True}"/>
                    </StackPanel>

                    <StackPanel Orientation="Horizontal">
                        <Label Content="תאור: " />
                        <Label Content="{Binding Path=Details, IsAsync=True}"/>
                    </StackPanel>

                    <StackPanel Orientation="Horizontal">
                        <Label Content="סוג מוצר: " />
                        <Label Content="{Binding Path=Type, IsAsync=True}"/>
                    </StackPanel>

                    <StackPanel Orientation="Horizontal">
                        <Label Content="יצרן: " />
                        <Label Content="{Binding Path=Manufacturer, IsAsync=True}"/>
                    </StackPanel>

                </StackPanel>

            </TreeViewItem>
        </DataTemplate>

        <DataTemplate x:Key="CategoryTemplate">
            <StackPanel Orientation="Vertical">
                <TreeViewItem Header="{Binding Path=Name, IsAsync=True}" ItemsSource="{Binding Path=Products, IsAsync=True}" ItemTemplate="{StaticResource ResourceKey=ProductTemplate}" />
            </StackPanel>
        </DataTemplate>

        <DataTemplate x:Key="ProviderTemplate">
            <StackPanel Orientation="Vertical">
                <StackPanel Orientation="Horizontal">
                    <Label Content="שם: " />
                    <Label Content="{Binding Path=Name, IsAsync=True}" />
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <Label Content="כתובת: " />
                    <Label Content="{Binding Path=CategoriesUri, IsAsync=True}" />
                </StackPanel>
            </StackPanel>
        </DataTemplate>
    </Window.Resources>

    <StackPanel>

        <TextBox Name="Url"></TextBox>
        <Button Content="הורד מידע" Click="Button_Click"></Button>

        <Label Content="רשימת קטגוריות:" />

        <TreeView 
                    ItemTemplate="{StaticResource ResourceKey=CategoryTemplate}" 
                    ItemsSource="{Binding Categories}"
                Height="400"/>

    </StackPanel>
</Window>
